package exam;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class EX03_AccountDAO 
											implements EX03_IAccountDAO {

	
	
	
	private String DRV = "";
	private String URL = "";
	private String insertSQL = "insert into Accountv2 values ( ?, ?, ?, sysdate )";
	private String selectSQL = "";
	private String updateSQL = "";
	private String deleteSQL = "";
	
	
	
	
	
	
	
	
	
	@Override
	public boolean insertAccount(EX03_AccountVO avo) {
		Connection conn = null;
		PreparedStatement pstmt  = null;
		boolean result = false;
		
		try{
			conn = openDatabase();
			pstmt = conn.prepareStatement(insertSQL);
				pstmt.setString(1, avo.getAid() );
				pstmt.setString(2, avo.getBalance() );
				pstmt.setString(3, avo.getInterestRate() );
			pstmt.executeUpdate();
			result = true;
				
				
		}catch ( Exception ex) {
			ex.printStackTrace();
		} finally {
			closeDatabase(conn, pstmt, null);
		}
		
		
		
		
		return result;
	} 

	
	private Connection openDatabase(){
		
		return null;
	}
	
	private void closeDatabase( Connection c, PreparedStatement p, ResultSet r ) {
		
		if ( r != null ) try {  r.close();   r=null;  } catch ( Exception ex ) {}
		if ( p != null ) try {  p.close();   p=null;  } catch ( Exception ex ) {}
		if ( c != null ) try {  c.close();   c=null;  } catch ( Exception ex ) {}
		
		
	}
	
	
	
} //class
